home *** CD-ROM | disk | FTP | other *** search
- Path: locutus.rchland.ibm.com!usenet
- From: pstaite@vnet.ibm.com
- Newsgroups: comp.lang.c++
- Subject: Re: Time countdown
- Date: 10 Jan 1996 21:44:30 GMT
- Organization: IBM OS/2 Device Driver Development Rochester, MN
- Message-ID: <4d1bvu$qn6@locutus.rchland.ibm.com>
- References: <723_9601092245@medtechnet.com>
- Reply-To: pstaite@vnet.ibm.com
- NNTP-Posting-Host: warpone.rchland.ibm.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <723_9601092245@medtechnet.com>, Tony.Johnston@dreams.medtechnet.com (Tony Johnston) writes:
- > I am using Borland C++ 4.00. I am writing a program that I would like to
- >have a 10 second delay in it. I would like it to be a visual countdown from
- >10 to 1 and I have no idea how to do this. Can anyone offer some sample code
- >on how this is done?
-
- #include<stdlib.h>
-
-
-
- for( int i = 10 ; i > 0 ; --i ) {
- // update display with value of i
- sleep( 1 ); }
-
- Should give you an approximation. If you want to make sure you don't
- miss a second. (sleep only guarantees you'll sleep for at least that
- long) You could use delay() and check the time() more often than once a
- second, and only update the display when the second count changes.
-
-
- Phil Staite, team OS/2
- internet: pstaite@vnet.ibm.com internal: pstaite@rchland
-
-